from SymGroup import *

class Signature(SymGroup):
    def __init__(self):
        super().__init__()

    def key_gen(self):
        """ generate a key pair dictionary that contains 'sk' and 'pk' """
        pass

    def signature(self, m, sk):
        """ apply the secret key (sk) on message (m) to generate digital signature """
        pass

    def verify(self, m, sig, pk):
        """ return a boolean value indicate the signature is legal or not """
        pass

    def test(self, m):
        if type(m) != bytes:
            m = bytes(str(m), encoding = 'utf-8')
        print('message: ', m)
        key_pair = self.key_gen()
        print('key_pair: ', key_pair)
        sig = self.signature(m, key_pair['sk'])
        print('signature: ', sig)
        assert self.verify(m, sig, key_pair['pk']), 'signature illegal'
        print('signature legal')
